@import './abstracts/variable';
@import './abstracts/mixin';

@include b(input) {
  position: relative;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  
  &::after {
    position: absolute;
    content: '';
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: $-input-border-color;
    transform: scaleY(0.5);
  }
  @include when(textarea) {
    &::after {
      display: none;
    }
  }
  @include e(label) {
    width: $-input-cell-label-width;
    color: $-cell-title-color;
    box-sizing: border-box;
    font-size: $-cell-title-fs;
    flex-shrink: 0;
    line-height: 1.43;
  }
  @include e(label-inner) {
    display: inline-block;
    padding: $-input-label-padding;
  }
  @include e(prefix) {
    margin-right: $-input-icon-margin;
  }
  @include e(suffix) {
    flex-shrink: 0;
    margin-left: $-input-icon-margin;
  }
  @include e(block) {
    position: relative;
    display: flex;
  }
  @include when(disabled) {
    .wd-input__inner, .wd-input__textarea-inner {
      color: $-input-disabled-color;
      background: transparent;
    }
  }
  @include when(error) {
    &::after {
      background: $-input-error-color;
    }
    .wd-input__inner, .wd-input__textarea-inner {
      color: $-input-error-color;
      background: transparent;

      &::-webkit-input-placeholder {
        color: $-input-error-color;
      }
    }
  }
  @include when(cell) {
    display: flex;
    align-items: flex-start;
    padding: 0 $-input-cell-padding;
    background-color: #fff;
    @include halfPixelBorder('bottom', $-input-cell-padding);

    &.is-error::after {
      background: $-input-cell-border-color;
    }
    .wd-input__textarea, .wd-input__block {
      flex: 1;
    }
    .wd-input__icon {
      height: $-input-cell-height;
      line-height: $-input-cell-height;
    }
    .wd-input__prefix {
      display: inline-block;
    }
    .wd-input__inner {
      height: $-input-cell-height;
    }
    @include when(center) {
      align-items: center;
    }
    &:last-child::after {
      display: none;
    }
  }
  @include when(large) {
    .wd-input__label {
      font-size: $-cell-title-fs-large;
    }
    .wd-input__inner {
      font-size: $-input-fs-large;
      height: $-input-cell-height-large;
    }
    .wd-input__textarea-inner {
      font-size: $-input-fs-large;
    }
    .wd-input__count {
      font-size: $-input-count-fs-large;
    }
    .wd-input__textarea-count {
      font-size: $-input-count-fs-large;
    }
    .wd-input__icon {
      height: $-input-cell-height-large;
      font-size: $-input-icon-size-large;
      line-height: $-input-cell-height-large;
    }
    .wd-input__textarea-icon {
      font-size: $-input-icon-size-large;
    }
  }
  @include e(inner) {
    display: block;
    flex: 1;
    height: $-input-inner-height;
    padding: $-input-inner-padding;
    font-size: $-input-fs;
    color: $-input-color;
    outline: none;
    border: none;
    box-sizing: border-box;

    &::-webkit-input-placeholder {
      color: $-input-placeholder-color;
    }
  }
  @include e(icon) {
    display: inline-block;
    margin-left: 8px;
    font-size: $-input-icon-size;
    color: $-input-icon-color;
    vertical-align: middle;
    height: $-input-inner-height;
    line-height: $-input-inner-height;
    background: #fff;

    &:first-child {
      margin-left: 0;
    }
  }
  @include e(count) {
    margin-left: 8px;
    font-size: $-input-count-fs;
    color: $-input-count-color;
    vertical-align: middle;
    height: $-input-inner-height;
    line-height: $-input-inner-height;
    background: #fff;
  }
  @include e(count-current) {
    color: $-input-count-current-color;

    @include when(error) {
      color: $-input-error-color;
    }
  }

  @include e(textarea) {
    position: relative;
    padding: $-input-textarea-padding;
    font-size: 0;
    background: #fff;
    
    @include when(show-limit) {
      padding-bottom: 25px;
    }
    @include when(text-auto) {
      padding: $-input-inner-padding;

      .wd-input__textarea-suffix {
        top: 10px;
        right: 0;
      }
    }
  }
  @include e(textarea-inner) {
    width: 100%;
    padding: 0;
    font-size: $-input-fs;
    line-height: 1.214;
    color: $-input-color;
    overflow: auto;
    outline: none;
    box-sizing: border-box;
    border: none;

    &::-webkit-input-placeholder {
      color: $-input-placeholder-color;
    }
    @include when(suffix) {
      padding-right: 20px;
    }
  }
  @include e(textarea-suffix) {
    position: absolute;
    right: 14px;
    top: 15px;
    bottom: 0;
    z-index: 1;
  }
  @include e(textarea-icon) {
    margin-left: 8px;
    font-size: $-input-icon-size;
    line-height: 20px;
    color: $-input-icon-color;
    background: #fff;
  }
  @include e(textarea-count) {
    position: absolute;
    bottom: 6px;
    right: 0;
    font-size: $-input-count-fs;
    color: $-input-count-color;
    background: #fff;
  }
  @include e(textarea-count-current) {
    color: $-input-count-current-color;

    @include when(error) {
      color: $-input-error-color;
    }
  }
}